﻿#include "LegendBase.h"

// LegendBase::LegendBase(QGraphicsItem *parent) {}

void LegendBase::append(const QString &legend)
{
    mLegends.append(legend);
    setText(mLegends.join('\n'));
}

void LegendBase::append(const QStringList &legends)
{
    mLegends.append(legends);
    setText(mLegends.join('\n'));
}

bool LegendBase::insert(unsigned int index, const QString &legend)
{
    if(index>mLegends.size())
        return false;
    mLegends.insert(index,legend);
    setText(mLegends.join('\n'));
    return true;
}

bool LegendBase::insert(unsigned int index, const QStringList &legends)
{
    if(index>mLegends.size())
        return false;
    for(auto& legend:legends)
        mLegends.insert(index++,legend);
    setText(mLegends.join('\n'));
    return true;
}

void LegendBase::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
    QGraphicsSimpleTextItem::paint(painter,option,widget);
}
